package com.applcn.goods.constant;

/**
 * com.applcn.goods.constant
 * Description:
 *
 * @author: 大妖怪
 * @date: 2020-02-25 00:38
 */
public enum  OnSaleStatusEnum {

    /**
     * 下架
     */
    OFF(0, "下架"),

    /**
     * 上架
     */
    ON(1, "上架");

    private int code;

    private String desc;

    OnSaleStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static boolean checkStatus(int code){
        for (OnSaleStatusEnum onSaleStatusEnum:OnSaleStatusEnum.values()) {
            if (onSaleStatusEnum.getCode() == code) {
                return true;
            }
        }
        return false;
    }

    public static OnSaleStatusEnum getStatus(int code){
        for (OnSaleStatusEnum onSaleStatusEnum:OnSaleStatusEnum.values()) {
            if (onSaleStatusEnum.getCode() == code) {
                return onSaleStatusEnum;
            }
        }

        return null;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
